package com.mgr.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class EmailController {
	@Autowired
	private JavaMailSender mailSender;
	
	@RequestMapping(value = "/send.do")
	public String doSendEmail(HttpServletRequest request) {

		
		// creates a simple e-mail object
		SimpleMailMessage email = new SimpleMailMessage();
		email.setTo("diemnt.pnv@gmail.com");
		email.setSubject("Tinh yeu khong noi nen loi");
		email.setText("Mot ngay nhu moi ngay.Ranh roi de so");
		
		// sends the e-mail
		mailSender.send(email);
		
		// forwards to the view named "Result"
		return "Result";
	}
}
